package com.my.main;

import com.my.main.common.utils.IdWorker;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

//1.配置springboot的包扫描
@SpringBootApplication(scanBasePackages = "com.my")
//2.配置扫描包
@MapperScan(value = "com.my.main.mapper")
@ServletComponentScan(basePackages = " com.my.main.component")
@EnableEurekaClient
public class MainApplication extends SpringBootServletInitializer {

    /**
     * 启动方法
     */
    public static void main(String[] args) {
        SpringApplication.run(MainApplication.class,args);
    }
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder)
    {
        return builder.sources(MainApplication.class);
    }

    @Bean
    public IdWorker idWorker() {
        return new IdWorker();
    }

    @Bean
    RestTemplate restTemplate(){
        return new RestTemplate();
    }

}
